lispy = {
    SOI ~
    expr+ ~
    EOI
}

whitespace = {(" " | "\t" | "\n" | "\n\r")+}

expr = {
    (value | compound_expr | initial_expression) ~
    whitespace?
}
expr_start = {"("}
expr_end = {")"}

compound_expr = {
    expr_start ~ whitespace? ~
    operator ~ whitespace? ~
    expr+ ~ whitespace? ~
    expr_end
}

initial_expression = {
    operator ~ whitespace? ~ expr+
}

operator = {"+" | "-" | "*" | "/" | "%"}

value = {number}

number = {
    (algebraic_sign? ~ ASCII_DIGIT+ ~ decimal_dot ~ ASCII_DIGIT+) |
    (algebraic_sign ~ ASCII_DIGIT+) |
    (algebraic_sign? ~ decimal_dot ~ ASCII_DIGIT+) |
    ASCII_DIGIT+
}

algebraic_sign = {
    ("-" | "+")
}

decimal_dot = {
    "."
}
